package com.model.demo.designmodel.observer.gper;

import java.util.Observable;

/**
 * 被观察者
 */
public class GPer extends Observable {
    private  String  name= "GPer生态圈";

    public  String getName() {
        return name;
    }

    private GPer() {
    }

    private static GPer gper = null;

    public static GPer getInstance(){
        if(gper==null){
            gper=new GPer();
        }
        return gper;

    }

    public void publishQuesion(Question question){
        System.out.println(question.getUserName() + "在" + this.name + "上提了一个问题！");
        //通知一个清除一个
        setChanged();
        //循环通知观察者
        notifyObservers(question);
    }


}
